package com.baidu.service.impl;

import com.baidu.model.entity.UserModel;
import com.baidu.model.entity.example.UserModelExample;
import com.baidu.model.mapper.UserModelMapper;
import com.baidu.service.InUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author user
 */
@Service
public class UserServiceImpl implements InUserService {
    @Autowired
    private UserModelMapper userInfoMapper;

    @Override
    public UserModel userLogin(String username, String userPassword) throws Exception{
        UserModelExample userInfoExample = new UserModelExample();
        userInfoExample.createCriteria().andNameEqualTo(username).andPasswordEqualTo(userPassword);
        return userInfoMapper.selectByExample(userInfoExample).get(0);
    }

    @Override
    public UserModel getUserInfo(Integer userId) throws Exception{
        return userInfoMapper.selectByPrimaryKey(userId);
    }
}
